module.exports = {
    render: function () {

        this.$el.append('<p>object 对象</p>');
        this.$el.append('<br>');
        var converArrayToObjTextarea = new icu.formElement.textarea({});
        converArrayToObjTextarea.set(JSON.stringify([{ id: 'id1', value: 'a' }, { id: 'id2', value: 'b' }, { id: 'id3', value: 'c' }, { id: 'id4', value: 'd' }]));
        converArrayToObjTextarea.html.appendTo(this.$el);

        this.$el.append('<p>key 值</p>');
        this.$el.append('<br>');
        var converArrayToObjInput = new icu.formElement.input({});
        converArrayToObjInput.html.css({
            width: '300px'
        });
        converArrayToObjInput.html.appendTo(this.$el);
        this.$el.append('<br>');
        var converArrayToObjAns = $('<div></div>').appendTo(this.$el);
        this.$el.append('<br>');
        $('<button type="button" class="layui-btn layui-btn-normal">返回对象key值数组</button>').click(function () {
            try {
                var _obj = {};
                converArrayToObjTextarea.get((error, value) => {
                    var json = {};
                    eval('json = ' + value);
                    _obj = json;
                });
                var key = '';
                converArrayToObjInput.get((error, value) => {
                    key = value;
                });
                var ans = icu.util.converArrayToObj(_obj, key);
                converArrayToObjAns.html(`
                返回转换对象:${JSON.stringify(ans, '<br>', 4)}
                `);
            } catch (error) {
                alert(error);
            };
        }).appendTo(this.$el);
    },
};